package log

import (
	"path/filepath"
)

type StreamLogger struct {
	Stdin  IOLogger
	Stdout IOLogger
	Stderr IOLogger
}

func NewStreamLogger(dir string) (*StreamLogger, error) {
	stdin, err := NewIOLogger(filepath.Join(dir, "stdin.log"))
	if err != nil {
		return nil, err
	}
	stdout, err := NewIOLogger(filepath.Join(dir, "stdout.log"))
	if err != nil {
		return nil, err
	}
	stderr, err := NewIOLogger(filepath.Join(dir, "stderr.log"))
	if err != nil {
		return nil, err
	}
	return &StreamLogger{
		Stdin:  stdin,
		Stdout: stdout,
		Stderr: stderr,
	}, nil
}

func (loggers *StreamLogger) Start() {
	loggers.Stdin.Start()
	loggers.Stdout.Start()
	loggers.Stderr.Start()
}

func (loggers *StreamLogger) Close() {
	loggers.Stdin.Close()
	loggers.Stdout.Close()
	loggers.Stderr.Close()
}

type ReadConfig struct {
	Since  int64
	Tail   int
	Follow bool
}
